	
var vue = new Vue({
  el: '#pageDiv',
  data :{
	  tableData : [],
	  loading: false,
	  currentPage : 1,
	  pagesize : 10,
	  totalSize : 10,
	  //url
	  queryUrl:COMMON_URL.URL+'material/pageList',
	  deleteUrl: COMMON_URL.URL+'material/deleteMateria',
	  visible2: false,
	  dialogEdit:false,
	  dialogAdd:false,
	  dialogTitle:'',
	  pollingConfig:{
		  id:'',
		  kanbanPoition:'',
		  kanbanUrl :''
	  },
	  pollingConfigAdd:{
		  kanbanPoition:'',
		  kanbanUrl :''
	  },
	  //form校验规则
	  rules:{
		  kanbanPoition:[
            { required: true, message: '请输入看板位置', trigger: 'blur' }
          ],
          kanbanUrl:[
	        { required: true, message: '请输入看板对应URL', trigger: 'blur' }
	      ]
	  }
  },
  methods:{
	  
	  dateFormat(row,col){
		  
		  var date = row[col.property];
		  if(date == null){
			  return '';
		  }
		  return moment(date).format('YYYY-MM-DD HH:mm:ss');
	  },
	  //查询数据
	  loadData(pageNum,pageSize){
		  $.ajax({
				url : this.queryUrl,
				dataType : 'json',
				type : 'get',
				data : {pageNum:pageNum,pageSize:pageSize},
				success : function(data){
					if(data.ok){
						var value = data.data.list;
						vue.tableData = value;
						vue.currentPage = data.data.currentPage;
						vue.totalSize = data.data.allCounts;
					}
				}
		  });
	  },
	  //分页
	  handleSizeChange(val){
		this.pagesize = val;
		this.loadData(this.currentPage,this.pagesize);
	  },
	  //分页
	  handleCurrentChange(val){
		this.currentPage = val;
		this.loadData(this.currentPage,this.pagesize);
	  },
      //删除看板配置
      deleteConfig(index,row,value){
		  const h = this.$createElement;
		  this.$msgbox({
			  title : "警告",
			  message : h('p', null, [
	            h('span', null, '你将要删除 '),
	            h('i', { style: 'color: teal' }, row.name),
	            h('span', null, ' ?'),
	          ]),
	          showCancelButton: true,
	          confirmButtonText: '确定',
	          cancelButtonText: '取消',
	          beforeClose: (action, instance, done) => {
	              if (action === 'confirm') {
	                instance.confirmButtonLoading = true;
	                instance.confirmButtonText = '执行中...';
	        		$.ajax({
	        			type : 'get',
	        			dataType : 'json',
	        			data : {id : row.id},
	        			url : this.deleteUrl,
	        			success : function(data){
	        				if(data.ok){
	        					done();
	        					value.splice(index,1);
	        					setTimeout(() => {
	                				instance.confirmButtonLoading = false;
	                			}, 300);
	        					vue.$message({
	        			        	  showClose: true,
	        			              type: 'success',
	        			              message: '操作成功'
	        			          });
	        				}else{
	        					
	        					done();
	        					setTimeout(() => {
	                				instance.confirmButtonLoading = false;
	                			}, 300);
	        					vue.$message({
	        			        	  showClose: true,
	        			              type: 'warning',
	        			              message: data.msg
	        			          });
	    					}
	        			}
	        		});
	              }else{
	                done();
	              }
	          }
		  });
	  }
   }
});
	

//载入数据
vue.loadData(vue.currentPage, vue.pagesize);

